import uuid
from typing import Any

import pytest

from recruit.application.commands.get_user import GetUser
from recruit.domain.exceptions.user import UserNotFoundException
from recruit.domain.models.user_id import UserId
from recruit.domain.services.user import UserService
from tests.gateway import UserGateway


@pytest.mark.parametrize(
    'data', [
        {
            'user_id': 1,
            'username': '@username'
        }
    ]
)
async def test_get_user(data: dict[str, Any]) -> None:
    user_id: UserId = uuid.uuid4()  # type: ignore
    reading_user = GetUser(
        user_db_gateway=UserGateway(user_id=user_id),
        user_service=UserService()
    )
    user = await reading_user(data['user_id'])
    assert user.id == user_id
    assert user.username == data['username']
    assert user.user_id == data['user_id']
    reading_user = GetUser(
        user_db_gateway=UserGateway(user_id=None),
        user_service=UserService()
    )
    with pytest.raises(UserNotFoundException):
        await reading_user(data['user_id'])
